{% macro pagination_widget(pagination, endpoint,count,pagesize, fragment='') %}
<ul class="pagination">
    <li><a>总数{{ count }}</a></li>
    <li{% if not pagination.has_prev %} class="disabled"{% endif %}>
        <a href="{% if pagination.has_prev %}{{ url_for(endpoint, page=pagination.prev_num, pagesize = pagesize, **kwargs) }}{% else %}#{% endif %}">
            &laquo;
        </a>
    </li>
    {% for p in pagination.iter_pages() %}
        {% if p %}
            {% if p == pagination.page %}
            <li class="active">
                <a href="{{ url_for(endpoint, page = p, pagesize = pagesize, **kwargs) }}">{{ p }}</a>
            </li>
            {% else %}
            <li>
                <a href="{{ url_for(endpoint, page = p, pagesize = pagesize, **kwargs) }}">{{ p }}</a>
            </li>
            {% endif %}
        {% else %}
        <li class="disabled"><a href="#">&hellip;</a></li>
        {% endif %}
    {% endfor %}
    <li{% if not pagination.has_next %} class="disabled"{% endif %}>
        <a href="{% if pagination.has_next %}{{ url_for(endpoint, page=pagination.next_num, pagesize = pagesize, **kwargs) }}{% else %}#{% endif %}">
            &raquo;
        </a>
    </li>
    <li>
       <span class="select-box inline">
            <select name="pagesize" id="pagesize" class="select">
                <option value="20">条数</option>
                <option value="20" {% if pagesize==20 %}selected{% endif %}>20条</option>
                <option value="50" {% if pagesize==50 %}selected{% endif %}>50条</option>
                <option value="100" {% if pagesize==100 %}selected{% endif %}>100条</option>
                <option value="150" {% if pagesize==150 %}selected{% endif %}>150条</option>
                <option value="200" {% if pagesize==200 %}selected{% endif %}>200条</option>
                <option value="300" {% if pagesize==300 %}selected{% endif %}>300条</option>
                <option value="400" {% if pagesize==400 %}selected{% endif %}>400条</option>
            </select>
        </span>
    </li>
</ul>
<script>
    $("#pagesize").change(function(e){
        document.location.href = "?pagesize="+e.currentTarget.value;
    })
</script>
{% endmacro %}